#!/usr/bin/env python3
"""
启动 OpenAI 兼容清洗代理服务的脚本
"""

import subprocess
import sys
import os
from pathlib import Path

def main():
    # 获取项目根目录
    project_root = Path(__file__).parent.parent
    proxy_script = project_root / "gateway" / "openai_clean_proxy.py"
    
    # 确保在项目根目录运行
    os.chdir(project_root)
    
    # 启动代理服务
    print("Starting OpenAI Compatible Clean Proxy...")
    print("Proxy will be available at http://0.0.0.0:8002")
    print("Press Ctrl+C to stop the service")
    
    try:
        # 使用 uv 运行代理服务
        subprocess.run([
            "uv", "run", 
            str(proxy_script)
        ], check=True)
    except subprocess.CalledProcessError as e:
        print(f"Error starting proxy service: {e}")
        sys.exit(1)
    except KeyboardInterrupt:
        print("\nProxy service stopped")
        sys.exit(0)

if __name__ == "__main__":
    main()